package com.ymatou.iapi.sellerquery.testcase;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.sellerquery.parameter.GetOrderTradeflowBean;
import com.ymatou.iapi.sellerquery.parameter.resp.OrderTradeflowResp;
import com.ymatou.iapi.sellerquery.service.GetOrderTradeflowCall;
import com.ymatou.iapi.trading.operate.parameter.ActivityVo;
import com.ymatou.iapi.trading.operate.parameter.OrderGroupVo;
import com.ymatou.iapi.trading.operate.parameter.OrderItemVo;
import com.ymatou.iapi.trading.operate.parameter.OrderVo;
import com.ymatou.iapi.trading.operate.parameter.SellerCouponVo;
import com.ymatou.iapi.trading.operate.parameter.YmatouCouponVo;
import com.ymatou.iapi.trading.operate.parameter.enums.ActivityPromotionTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.AppTerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.LogisticsTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.OrderSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.OrderTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.PriceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.ProductRefundChannelEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.SalesTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.SellerCouponApplianceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.TerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.YmatouCouponApplianceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.req.PlaceOrderReq;
import com.ymatou.iapi.trading.operate.parameter.req.SalesRefundSuccessRequestBean;
import com.ymatou.iapi.trading.operate.service.PlaceOrderCall;
import com.ymatou.iapi.trading.operate.service.SalesRefundSuccessRequestCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponCallService;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.business.service.ProductCallService;
import com.ymttest.database.model.YmtRefundBill;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.database.sqlwapper.YmtRefundWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;
/**
*获取订单退货退款信息
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetOrderTradeflow{
	private static GetOrderTradeflowBean getordertradeflowBean;
	private static GetOrderTradeflowCall getordertradeflowCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取单个订单信息");
	}

	@Before
	public void caseUp() {
		getordertradeflowBean=new GetOrderTradeflowBean();
		getordertradeflowCall=new GetOrderTradeflowCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getordertradeflowCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	private String formatDate(Object date){
		if (date==null)
			return null;
		else {
			String dateString=date.toString();		
			return dateString.split("\\.")[0].replace(" ", "T");
		}		
	}
	   // 一个订单下面多个商品
    private Map placeOrder() {
        Map map = new HashMap();
        try {
            PlaceOrderReq placeorderBean = new PlaceOrderReq();
            PlaceOrderCall placeorderCall = new PlaceOrderCall();
            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            // 创建产品
            Logger.comment("前置数据准备");
            HashMap<String, Object> productInfo = ProductCallService
                    .createProduct(sellerId, 3);
            Logger.comment("前置数据准备结束");
            String productId = (String) productInfo.get("productId");
            Logger.debug("productId:" + productId);
            String productName = (String) productInfo.get("productName");
            String pic = (String) productInfo.get("pic");
            BigDecimal price = (BigDecimal) (productInfo.get("price"));
            String catalogId = (String) productInfo.get("catalogId");
            YmatouCouponVo ymtCoupon = new YmatouCouponVo();
            // 平台优惠券
            BigDecimal couponValue = new BigDecimal(13);
            String couponCode = new OrderCallService().receivePlatformCoupon(userId, couponValue);
            ymtCoupon.setApplianceType(YmatouCouponApplianceTypeEnum.ALL);
            ymtCoupon.setCouponCode(couponCode);
            ymtCoupon.setCouponValue(couponValue);
            placeorderBean.setAppId("AutoTest");
            placeorderBean.setYmatouCoupon(ymtCoupon);
            placeorderBean.setUserId(userId);
            placeorderBean.setRequestId(TestDataManager.getRandomUUID()
                    .toString());
            placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
            placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
            placeorderBean.setSourceIp("127.0.0.1");
            placeorderBean.setAppId("ios");
            placeorderBean.setDeviceId("7777777777888888888888999");
            OrderGroupVo groupVo1 = new OrderGroupVo();
            placeorderBean.setOrderSource(OrderSourceEnum.PC);
            // 商家优惠券
            BigDecimal sellerCouponValue = new BigDecimal(15);
            String sellerCouponCode = new CouponCallService().receiveCouponInfo(sellerId, userId,
                    couponValue);
            SellerCouponVo sellerCoupon = new SellerCouponVo();
            sellerCoupon.setApplianceType(SellerCouponApplianceTypeEnum.ALL);
            sellerCoupon.setCouponCode(sellerCouponCode);
            sellerCoupon.setCouponValue(sellerCouponValue);
            groupVo1.setSellerCoupon(sellerCoupon);
            groupVo1.setSellerId(sellerId);
            List<OrderVo> orders = new ArrayList<OrderVo>();
            OrderVo ordervo1 = new OrderVo();
            ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
            ordervo1.setOrderType(OrderTypeEnum.Spot);
            ordervo1.setPaidFull(true);
            ordervo1.setAddress("上海市闸北区灵石路636号");
            ordervo1.setLeaveWord("ymt autotest");
            ordervo1.setPhone("13100000001");
            ordervo1.setPostCode("200001");
            ordervo1.setTelephone("021-51002100");
            ordervo1.setReceiveName("李四");
            List<OrderItemVo> items = new ArrayList<OrderItemVo>();
            OrderItemVo orderitem1 = new OrderItemVo();
            orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
            orderitem1.setProductNum(3);
            orderitem1.setProductName(productName);
            orderitem1.setPriceType(PriceTypeEnum.VipPrice);
            orderitem1.setProductId(TestDataManager.getRandomUUID().toString());
            price = new BigDecimal(210);
            orderitem1.setEarnestPrice(price);
            orderitem1.setProductPrice(price);
            orderitem1.setOriginalPrice(price);
            orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
            orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
            orderitem1.setProductRefundChannel(ProductRefundChannelEnum.Official);
            orderitem1.setBrandId(5);
            orderitem1.setPackageNo("11111111");
            orderitem1.setFirstCategoryId(111111111);
            orderitem1.setSecondCategoryId(22222222);
            orderitem1.setThirdCategoryId(3333333);
            orderitem1
                    .setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
            orderitem1.setProductRecordNo("1234567");
            orderitem1.setProductRefundChannel(ProductRefundChannelEnum.Official);
            orderitem1
                    .setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
            ActivityVo activity = new ActivityVo();
            activity.setActivityId(46870);
            activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10, "yyyy-MM-dd'T'HH:mm:ss"));
            activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10, "yyyy-MM-dd'T'HH:mm:ss"));
            activity.setActivityTemplateId(12345678);
            activity.setCommissionRate(new BigDecimal(1.1));
            activity.setCost(true);
            activity.setFeeFree(false);
            activity.setPremium(new BigDecimal(1.5));
            activity.setPromotionPrice(new BigDecimal(15));
            activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
            activity.setUseCoupon(true);
            orderitem1.setActivity(activity);
            ordervo1.setOrderItems(items);
            ordervo1.setFreight(new BigDecimal("21"));
            // 第2件商品
            OrderItemVo orderitem2 = new OrderItemVo();
            orderitem2.setCatalogId(TestDataManager.getRandomUUID().toString());
            orderitem2.setProductNum(1);
            orderitem2.setProductName(productName);
            orderitem2.setPriceType(PriceTypeEnum.VipPrice);
            orderitem2.setProductId(TestDataManager.getRandomUUID().toString());
            price = new BigDecimal(270);
            orderitem2.setEarnestPrice(price);
            orderitem2.setProductPrice(price);
            orderitem2.setOriginalPrice(price);
            orderitem2.setSalesType(SalesTypeEnum.AlreadyInStock);
            orderitem2.setLogisticsType(LogisticsTypeEnum.SailProtect);
            orderitem2.setProductRefundChannel(ProductRefundChannelEnum.Official);
            orderitem2.setBrandId(5);
            orderitem2.setPackageNo("11111111");
            orderitem2.setFirstCategoryId(111111111);
            orderitem2.setSecondCategoryId(22222222);
            orderitem2.setThirdCategoryId(3333333);
            orderitem2
                    .setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
            orderitem2.setProductRecordNo("1234567");
            orderitem2.setProductRefundChannel(ProductRefundChannelEnum.Official);
            orderitem2
                    .setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
            orderitem2.setActivity(activity);
            items.add(orderitem1);
            items.add(orderitem2);
            ordervo1.setOrderItems(items);
            ordervo1.setFreight(new BigDecimal("21"));
            orders.add(ordervo1);
            groupVo1.setOrders(orders);
            placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
            placeorderCall.setData(false, placeorderBean);
            placeorderCall.callService();
            JSONArray orderIds = placeorderCall.getOrderIds();
            int tradingId = placeorderCall.getTradingId();
            map.put("orderIds", orderIds);
            map.put("tradingId", tradingId);
        } catch (Exception e) {
            Logger.fail(e);
        }
        return map;
    }
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetOrderTradeflow_001() {
		Logger.start(true,"该订单有退款记录,获取单个订单信息成功");
		try {
            OrderCallService orderCallService = new OrderCallService();
            SalesRefundSuccessRequestBean salesrefundsuccessrequestBean=new SalesRefundSuccessRequestBean();
            SalesRefundSuccessRequestCall salesrefundsuccessrequestCall=new SalesRefundSuccessRequestCall();
            Map map = placeOrder();
            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            JSONArray orderIds = (JSONArray) map.get("orderIds");
            int tradingId = (Integer) map.get("tradingId");
            int orderId = orderIds.getInt(0);
            // 付款金额
            DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
            BigDecimal amount = orderCallService.getNeedPrePayAmountOfCash(orderId);
            // 付款
            orderCallService.orderPayRequest(userId, amount, tradingId);
            // 卖家接单
            orderCallService.acceptOrder(orderId, sellerId);
            // 申请退款
            orderCallService.applySalesRefundRequestInJava(orderId);
            salesrefundsuccessrequestBean.setOperatorInfo("autotest");
            salesrefundsuccessrequestBean.setOrderId(orderId);
            salesrefundsuccessrequestBean.setRefundBillNo("YMTTK0" + orderId);
            salesrefundsuccessrequestCall.setData(false,salesrefundsuccessrequestBean);
            Logger.comment("退该订单号" + orderId + "第一件商品");
            salesrefundsuccessrequestCall.callService();
            Logger.verifyEquals("ok", salesrefundsuccessrequestCall.getReturnData(), "验证退货退款成功返回");
            salesrefundsuccessrequestBean.setOrderId(orderId);
            salesrefundsuccessrequestBean.setRefundBillNo("YMTTK1" + orderId);
            salesrefundsuccessrequestCall.setData(false,salesrefundsuccessrequestBean);
            Logger.comment("退该订单号" + orderId + "第二件商品");
            salesrefundsuccessrequestCall.callService();      
            
            String param="OrderId="+orderId;
			getordertradeflowCall.setData(param);
			getordertradeflowCall.callService();			
			
			OrderTradeflowResp orderFlowsResp=getordertradeflowCall.getRefundFlowsResp();
			
	        DefaultWapper defaultWapper = new DefaultWapper();
            // 订单主表
            List<Map> ymtOrders =defaultWapper.selectOrderByOderId(orderId);     
            // 订单资金 表
            List<Map> ymtOrderState = defaultWapper.selectOrderStateByOderId(orderId);
            //订单交易表
            List<Map> ymtTradinginfo = defaultWapper.selectTradinginfoByTradingId(tradingId);
            
            //订单退款申请表
            YmtRefundWapper ymtRefund = new YmtRefundWapper();
            Map m = new HashMap();
            m.put("orderId", orderId);
            // 订单退货记录
            List<YmtRefundBill> refundBill = ymtRefund.selectRefundBill(m);
					
			Logger.verifyEquals(ECode.SUCCESS, getordertradeflowCall.getCode(), "验证code");
			Logger.verifyEquals(0, getordertradeflowCall.getBCode(), "验证bcode");
			Logger.verifyEquals(true, getordertradeflowCall.getData().getBoolean("success"), "验证success");		
			Logger.verifyEquals(orderId, orderFlowsResp.getOrderId(), "验证orderId");
						
			Logger.verifyEquals(formatDate(ymtOrders.get(0).get("dPaidTime")),orderFlowsResp.getPaidTime() , "验证paidTime");
			Logger.verifyEquals(formatDate(ymtOrders.get(0).get("dPostPaidTime")), orderFlowsResp.getPostPaidTime(), "验证postPaidTime");
			Logger.verifyEquals(formatDate(ymtOrders.get(0).get("dCancelTime")), orderFlowsResp.getCancelTime(), "验证cancelTime");
			Logger.verifyEquals((String)ymtOrders.get(0).get("sSellerCouponCode"), orderFlowsResp.getSellerCouponCode(), "验证sellerCouponCode");
			Logger.verifyEquals((BigDecimal)ymtOrders.get(0).get("fSellerCouponAmount"), orderFlowsResp.getSellerCouponAmount(), "验证sellerCouponAmount");
			Logger.verifyEquals((String)ymtOrders.get(0).get("sYmtCouponCode"), orderFlowsResp.getYmtCouponCode(), "验证ymtCouponCode");
			Logger.verifyEquals((BigDecimal)ymtOrders.get(0).get("fYmtCouponAmount"), orderFlowsResp.getYmtCouponAmount(), "验证ymtCouponAmount");
			Logger.verifyEquals((BigDecimal)ymtOrders.get(0).get("fFreight"), orderFlowsResp.getFreight(), "验证freight");
			Logger.verifyEquals((BigDecimal)ymtOrders.get(0).get("fDiscount"), orderFlowsResp.getDiscount(), "验证discount");
			Logger.verifyEquals((BigDecimal)ymtOrders.get(0).get("fOrderDiscount"), orderFlowsResp.getPostDiscount(), "验证postDiscount");
			Logger.verifyEquals((BigDecimal)ymtOrders.get(0).get("fTotalPrice"), orderFlowsResp.getTotalPrice(), "验证totalPrice");

			Logger.verifyEquals((String)ymtTradinginfo.get(0).get("sPayChannel"), orderFlowsResp.getPayChannel(), "验证payChannel");
			Logger.verifyEquals((Integer)ymtOrders.get(0).get("iTradingStatus"), orderFlowsResp.getTradingStatus(), "验证tradingStatus");
			Logger.verifyEquals((BigDecimal)ymtOrderState.get(0).get("fPaidAmountOfCash"), orderFlowsResp.getPaidAmountOfCash(), "验证paidAmountOfCash");
			Logger.verifyEquals((BigDecimal)ymtOrderState.get(0).get("fPostPaidAmountOfCash"), orderFlowsResp.getPostPaidAmountOfCash(), "验证postPaidAmountOfCash");
			Logger.verifyEquals((BigDecimal)ymtOrderState.get(0).get("fPostPaidAmountOfGift"), orderFlowsResp.getPaidAmountOfGift(), "验证paidAmountOfGift");
			Logger.verifyEquals(BigDecimal.ZERO.setScale(2), orderFlowsResp.getPaidAmountOfGift(), "验证paidAmountOfGift");
			Logger.verifyEquals(refundBill.size(), orderFlowsResp.getOrderTradeflowRefundList().size(), "验证该订单申请退款单数量");
			
			if (refundBill.size()>0){
				for(int i=0;i<refundBill.size();i++){				
					Logger.verifyEquals(refundBill.get(i).getOrderId(), orderFlowsResp.getOrderTradeflowRefundList().get(i).getOrderId(), "验证退款 orderId");
					Logger.verifyEquals(YMTDateUtil.getFormatTime(refundBill.get(i).getAddTime(), "yyyy-MM-dd'T'HH:mm:ss")
							, orderFlowsResp.getOrderTradeflowRefundList().get(i).getAddTime(), "验证退款 addTime");
					Logger.verifyEquals(refundBill.get(i).getRefundBillNo(), orderFlowsResp.getOrderTradeflowRefundList().get(i).getRefundBillNo(), "验证退款 refundBillNo");
					Logger.verifyEquals(refundBill.get(i).getRefundAmount(), orderFlowsResp.getOrderTradeflowRefundList().get(i).getRefundAmount(), "验证退款 refundAmount");
					Logger.verifyEquals(null, orderFlowsResp.getOrderTradeflowRefundList().get(i).getRefundChannel(), "验证退款 refundChannel");					
				}
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetOrderTradeflow_002() {
		Logger.start(true,"该订单没有退款记录,获取单个订单信息成功");
		try {
            OrderCallService orderCallService = new OrderCallService();
            SalesRefundSuccessRequestBean salesrefundsuccessrequestBean=new SalesRefundSuccessRequestBean();
            SalesRefundSuccessRequestCall salesrefundsuccessrequestCall=new SalesRefundSuccessRequestCall();
            Map map = placeOrder();
            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            JSONArray orderIds = (JSONArray) map.get("orderIds");
            int tradingId = (Integer) map.get("tradingId");
            int orderId = orderIds.getInt(0);

            String param="OrderId="+orderId;
			getordertradeflowCall.setData(param);
			getordertradeflowCall.callService();			
			
			OrderTradeflowResp orderFlowsResp=getordertradeflowCall.getRefundFlowsResp();
			
	        DefaultWapper defaultWapper = new DefaultWapper();
            // 订单主表
            List<Map> ymtOrders =defaultWapper.selectOrderByOderId(orderId);     
            // 订单资金 表
            List<Map> ymtOrderState = defaultWapper.selectOrderStateByOderId(orderId);
            //订单交易表
            List<Map> ymtTradinginfo = defaultWapper.selectTradinginfoByTradingId(tradingId);
            
            //订单退款申请表
            YmtRefundWapper ymtRefund = new YmtRefundWapper();
            Map m = new HashMap();
            m.put("orderId", orderId);
            // 订单退货记录
            List<YmtRefundBill> refundBill = ymtRefund.selectRefundBill(m);
					
			Logger.verifyEquals(ECode.SUCCESS, getordertradeflowCall.getCode(), "验证code");
			Logger.verifyEquals(0, getordertradeflowCall.getBCode(), "验证bcode");
			Logger.verifyEquals(true, getordertradeflowCall.getData().getBoolean("success"), "验证success");		
			Logger.verifyEquals(orderId, orderFlowsResp.getOrderId(), "验证orderId");
						
			Logger.verifyEquals((String)ymtOrders.get(0).get("dPaidTime"),orderFlowsResp.getPaidTime() , "验证paidTime");
			Logger.verifyEquals((String)ymtOrders.get(0).get("dPostPaidTime"), orderFlowsResp.getPostPaidTime(), "验证postPaidTime");
			Logger.verifyEquals((String)ymtOrders.get(0).get("dCancelTime"), orderFlowsResp.getCancelTime(), "验证cancelTime");
			Logger.verifyEquals((String)ymtOrders.get(0).get("sSellerCouponCode"), orderFlowsResp.getSellerCouponCode(), "验证sellerCouponCode");
			Logger.verifyEquals((BigDecimal)ymtOrders.get(0).get("fSellerCouponAmount"), orderFlowsResp.getSellerCouponAmount(), "验证sellerCouponAmount");
			Logger.verifyEquals((String)ymtOrders.get(0).get("sYmtCouponCode"), orderFlowsResp.getYmtCouponCode(), "验证ymtCouponCode");
			Logger.verifyEquals((BigDecimal)ymtOrders.get(0).get("fYmtCouponAmount"), orderFlowsResp.getYmtCouponAmount(), "验证ymtCouponAmount");
			Logger.verifyEquals((BigDecimal)ymtOrders.get(0).get("fFreight"), orderFlowsResp.getFreight(), "验证freight");
			Logger.verifyEquals((BigDecimal)ymtOrders.get(0).get("fDiscount"), orderFlowsResp.getDiscount(), "验证discount");
			Logger.verifyEquals((BigDecimal)ymtOrders.get(0).get("fOrderDiscount"), orderFlowsResp.getPostDiscount(), "验证postDiscount");
			Logger.verifyEquals((BigDecimal)ymtOrders.get(0).get("fTotalPrice"), orderFlowsResp.getTotalPrice(), "验证totalPrice");

			Logger.verifyEquals((String)ymtTradinginfo.get(0).get("sPayChannel"), orderFlowsResp.getPayChannel(), "验证payChannel");
			Logger.verifyEquals((Integer)ymtOrders.get(0).get("iTradingStatus"), orderFlowsResp.getTradingStatus(), "验证tradingStatus");
			Logger.verifyEquals((BigDecimal)ymtOrderState.get(0).get("fPaidAmountOfCash"), orderFlowsResp.getPaidAmountOfCash(), "验证paidAmountOfCash");
			Logger.verifyEquals((BigDecimal)ymtOrderState.get(0).get("fPostPaidAmountOfCash"), orderFlowsResp.getPostPaidAmountOfCash(), "验证postPaidAmountOfCash");
			Logger.verifyEquals((BigDecimal)ymtOrderState.get(0).get("fPostPaidAmountOfGift"), orderFlowsResp.getPaidAmountOfGift(), "验证paidAmountOfGift");
			Logger.verifyEquals(BigDecimal.ZERO.setScale(2), orderFlowsResp.getPaidAmountOfGift(), "验证paidAmountOfGift");
			Logger.verifyEquals(refundBill.size(), orderFlowsResp.getOrderTradeflowRefundList()==null?0:orderFlowsResp.getOrderTradeflowRefundList().size(), "验证该订单申请退款单数量");
			
			if (refundBill.size()>0){
				for(int i=0;i<refundBill.size();i++){				
					Logger.verifyEquals(refundBill.get(i).getOrderId(), orderFlowsResp.getOrderTradeflowRefundList().get(i).getOrderId(), "验证退款 orderId");
					//Logger.verifyEquals(refundBill.get(i).getAddTime(), orderFlowsResp.getOrderTradeflowRefundList().get(i).getAddTime(), "验证退款 addTime");
					Logger.verifyEquals(refundBill.get(i).getRefundBillNo(), orderFlowsResp.getOrderTradeflowRefundList().get(i).getRefundBillNo(), "验证退款 refundBillNo");
					Logger.verifyEquals(refundBill.get(i).getRefundAmount(), orderFlowsResp.getOrderTradeflowRefundList().get(i).getRefundAmount(), "验证退款 refundAmount");
					Logger.verifyEquals(null, orderFlowsResp.getOrderTradeflowRefundList().get(i).getRefundChannel(), "验证退款 refundChannel");					
				}
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetOrderTradeflow_003() {
		Logger.start(true,"订单号不存在,获取单个订单信息成功");
		try {
            int orderId = 111;

            String param="OrderId="+orderId;
			getordertradeflowCall.setData(param);
			getordertradeflowCall.callService();			
			
			OrderTradeflowResp orderFlowsResp=getordertradeflowCall.getRefundFlowsResp();
							
			Logger.verifyEquals(ECode.SUCCESS, getordertradeflowCall.getCode(), "验证code");
			Logger.verifyEquals(0, getordertradeflowCall.getBCode(), "验证bcode");
			Logger.verifyEquals(true, getordertradeflowCall.getData().getBoolean("success"), "验证success");		
			Logger.verifyEquals(null, orderFlowsResp, "验证orderTradeflow");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetOrderTradeflow_004() {
		Logger.start(true,"订单号为null,获取单个订单信息成功");
		try {

            String param="";
			getordertradeflowCall.setData(param);
			getordertradeflowCall.callService();			
			
			OrderTradeflowResp orderFlowsResp=getordertradeflowCall.getRefundFlowsResp();
							
			Logger.verifyEquals(ECode.ERROR400, getordertradeflowCall.getCode(), "验证code");
			Logger.verifyEquals(100, getordertradeflowCall.getBCode(), "验证bcode");
			Logger.verifyEquals("orderId:订单号不能为0", getordertradeflowCall.getMsg(), "验证msg");
			Logger.verifyEquals(false, getordertradeflowCall.getData().getBoolean("success"), "验证success");		
			Logger.verifyEquals(null, orderFlowsResp, "验证orderTradeflow");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}